package xyz.scootaloo.mono.test.web

import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import xyz.scootaloo.mono.base.lang.R
import xyz.scootaloo.mono.base.util.IpUtil
import javax.servlet.http.HttpServletRequest

/**
 * @author flutterdash@qq.com
 * @since 2021/8/7 20:15
 */
@RestController
@RequestMapping("/test/ip")
class IpUtilTest {

    @GetMapping("/get")
    fun showIpAddress(request: HttpServletRequest): R<String> {
        val ip = IpUtil.getRealIpAddress(request)
        return R.success(ip)
    }

    @PostMapping("/post")
    fun showIpByPost(request: HttpServletRequest): R<String> {
        val ip = IpUtil.getRealIpAddress(request)
        return R.success(ip)
    }

}
